<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/20
 * Time: 9:46
 * 角色模型
 */
namespace app\admin\model;

use think\Model;

class Roles extends Model
{
    public function getAllRoles()
    {
        $list = $this->where('status', 1)->column('id,name');
        return $list ?? [];
    }

    /**
     * @todo 验证角色是否存在
     * @param type $roles
     * @return boolean
     */
    public function validateRoles($roles)
    {
        if (empty($roles) || !is_array($roles)) {
            return false;
        }
        $ret = $this->where('id', 'IN', $roles)->select();
        if ($ret) {
            return true;
        } else {
            return false;
        }
    }
}